package health_system.health_system.service;


import health_system.health_system.dto.*;
import health_system.health_system.entity.MomentMedia;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;
import java.util.Optional;

public interface MomentMediaService {
    
    /**
     * Create a new moment media
     */
    MomentMediaDTO createMedia(MomentMediaCreateDTO createDTO);
    
    /**
     * Create media from uploaded file
     */
    MomentMediaDTO uploadMedia(MultipartFile file, Long momentId, MomentMedia.MediaType mediaType, Integer orderIndex);
    
    /**
     * Batch upload multiple media files
     */
    List<MomentMediaDTO> batchUploadMedia(List<MultipartFile> files, Long momentId);
    
    /**
     * Update existing media
     */
    MomentMediaDTO updateMedia(Long id, MomentMediaUpdateDTO updateDTO);
    
    /**
     * Delete media by ID
     */
    void deleteMedia(Long id);
    
    /**
     * Get media by ID
     */
    MomentMediaDTO getMediaById(Long id);
    
    /**
     * Get media entity by ID (for internal use)
     */
    MomentMedia getMediaEntityById(Long id);
    
    /**
     * Find media entity by ID (optional, for internal use)
     */
    Optional<MomentMedia> findMediaEntityById(Long id);
    
    /**
     * Get all media for a moment
     */
    List<MomentMediaDTO> getMediaByMomentId(Long momentId);
    
    /**
     * Get media by user ID
     */
    List<MomentMediaDTO> getMediaByUserId(Long userId);
    
    /**
     * Get paginated media by user ID
     */
    PageResponseDTO<MomentMediaDTO> getMediaByUserId(Long userId, Pageable pageable);
    
    /**
     * Get media by moment and type
     */
    List<MomentMediaDTO> getMediaByMomentIdAndType(Long momentId, MomentMedia.MediaType mediaType);
    
    /**
     * Count media by moment and type
     */
    Long countMediaByMomentIdAndType(Long momentId, MomentMedia.MediaType mediaType);
    
    /**
     * Get images visible to a user
     */
    List<MomentMediaDTO> getImagesVisibleToUser(Long viewerId, Pageable pageable);
    
    /**
     * Get videos visible to a user
     */
    List<MomentMediaDTO> getVideosVisibleToUser(Long viewerId, Pageable pageable);
    
    /**
     * Count media for a moment
     */
    Long countMediaByMomentId(Long momentId);
    
    /**
     * Delete all media for a moment
     */
    void deleteAllMediaForMoment(Long momentId);
    
    /**
     * Search media by filename for a user
     */
    List<MomentMediaDTO> searchMediaByUserAndFilename(Long userId, String filename);
    
    /**
     * Get moments with most media visible to user
     */
    List<MomentWithMediaStatsDTO> getMomentsWithMostMediaVisibleToUser(Long viewerId, Pageable pageable);
    
    /**
     * Reindex all moment media by their order
     */
    void reorderMedia(Long momentId, List<Long> mediaIds);
    
    /**
     * Batch get media counts for multiple moments
     */
    Map<Long, Long> batchGetMediaCountsForMoments(List<Long> momentIds);
    
    /**
     * Generate thumbnails for videos
     */
    String generateThumbnail(String videoUrl);
    
    /**
     * Optimize media for web display
     */
    String optimizeMediaForWeb(String mediaUrl, MomentMedia.MediaType mediaType);
    
    /**
     * Get media statistics by user
     */
    MediaStatsDTO getMediaStatsByUser(Long userId);
} 